package com.course.web.view;

import com.course.web.component.custom.ClassMarkGrid;
import com.course.web.page.AdminUI;
import com.vaadin.navigator.View;
import com.vaadin.navigator.ViewChangeListener;
import com.vaadin.spring.annotation.SpringView;
import com.vaadin.ui.CustomComponent;
import org.apache.commons.lang3.math.NumberUtils;

/**
 * Created by Justin on 2017/7/1.
 */
@SpringView(name = ClassMarkView.NAME, ui = AdminUI.class)
public class ClassMarkView extends CustomComponent implements View {
    public static final String NAME = "class-mark";

    private final ClassMarkGrid markGrid;

    public ClassMarkView(ClassMarkGrid markGrid) {
        this.markGrid = markGrid;
        setCompositionRoot(markGrid);
        setSizeFull();
    }

    @Override
    public void enter(ViewChangeListener.ViewChangeEvent event) {
        String parameters = event.getParameters();
        int studentId = NumberUtils.toInt(parameters);
        markGrid.enter(studentId);
    }
}
